package com.ruoyi.teaching.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.teaching.domain.WebSocketGroupUser;
import com.ruoyi.teaching.mapper.WebSocketGroupUserMapper;
import com.ruoyi.teaching.service.WebSocketGroupUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 李志鑫
 * @since 2024-12-07
 */
@Service
public class WebSocketGroupUserServiceImpl extends ServiceImpl<WebSocketGroupUserMapper, WebSocketGroupUser> implements WebSocketGroupUserService {
    @Autowired
    private WebSocketGroupUserMapper webSocketGroupUserMapper;

    @Override
    public AjaxResult updateGroupUser(WebSocketGroupUser webSocketGroupUser) {
        if (null!=webSocketGroupUser.getId()&&!webSocketGroupUser.getId().equals("")) {
            int i = webSocketGroupUserMapper.updateById(webSocketGroupUser);
            if (i == 0) {
                return new AjaxResult(HttpStatus.ERROR, "失败");
            }
        }else {
            int insert = webSocketGroupUserMapper.insert(webSocketGroupUser);
            if (insert == 0) {
                return new AjaxResult(HttpStatus.ERROR, "失败");
            }
        }
        return new AjaxResult(HttpStatus.SUCCESS, "成功");
    }

}
